package logic

import (
	"context"

	"mail/service/receipt/api/internal/svc"
	"mail/service/receipt/api/internal/types"
	"mail/service/receipt/rpc/receiptclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type SceneryLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSceneryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SceneryLogic {
	return &SceneryLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SceneryLogic) Scenery(req *types.SceneryRequest) (resp *types.SceneryResponse, err error) {
	// todo: add your logic here and delete this line
	reply, err := l.svcCtx.ReceiptRpc.Scenery(l.ctx, &receiptclient.SceneryRequest{
		Id: req.Id,
	})
	if err != nil {
		return nil, err
	}

	return &types.SceneryResponse{
		Id:     reply.Id,
		Uid:    reply.Uid,
		Pid:    reply.Pid,
		Amount: reply.Amount,
		Status: reply.Status,
	}, nil
}
